#import "HPSDYQMN_ModityJbuttonController.h"
#import "HPSDYQMN_PchController.h"
@interface gamevc ()
{
    int level;
    jlabel *judge;
    jlabel *levellab;
}
@end

@implementation gamevc

-(NSString *)TristimulusHydrocephalus:(NSString *)CalendarFosterage {
    NSString *decoration = [NSString new];

    return decoration;

}






-(void)tuilifixmodel{

         {
    [self TristimulusHydrocephalus:@"thesis"];

}

    [[framedic get] removeAllObjects];
    [[barr get] removeAllObjects];
    [[tvarr get] removeAllObjects];
    self.tview.frame = CGRectMake(0,0,0.9662*SCRWIDTH,(0.9662*SCRWIDTH/((NSArray *)self.levelarr[0]).count)*self.levelarr.count);
    float stoneW = 0.9662*SCRWIDTH/((NSArray *)self.levelarr[0]).count;
    if (((NSArray *)self.levelarr[0]).count == 4) {
        stoneW = 0.624*SCRWIDTH/4;
        self.tview.frame = CGRectMake(0,0,0.624*SCRWIDTH,(0.624*SCRWIDTH/4)*self.levelarr.count);
    }
    self.tview.center = CGPointMake(self.view.center.x, self.view.center.y);
    for (int i = 0; i<self.levelarr.count; i++) {
        for (int j = 0; j<((NSArray *)self.levelarr[i]).count;j++) {
            NSArray *listItems = [((NSArray *)self.levelarr[i])[j] componentsSeparatedByString:@"-"];
            if ([listItems[0] intValue] == 1) {
                bgview *bv = [[bgview alloc]initWithFrame:CGRectMake(j*stoneW,i*stoneW, stoneW, stoneW)];
                bv.x = j;bv.y = i;
                [[framedic get] setObject:[NSValue valueWithCGRect:CGRectMake(j*stoneW,i*stoneW, stoneW, stoneW)] forKey:[NSString stringWithFormat:@"%d%d",j,i]];
                ![listItems[1] isEqualToString:@"0"]?(bv.key = YES):(bv.key = NO);
                [self.tview addSubview:bv];
                [[barr get] addObject:bv];
            }
        }
    }
    for (int i = 0; i<self.levelarr.count; i++) {
        for (int j = 0; j<((NSArray *)self.levelarr[i]).count;j++) {
            NSArray *listItems = [((NSArray *)self.levelarr[i])[j] componentsSeparatedByString:@"-"];
            if ([listItems[0] intValue] == 0 && listItems.count == 2) {
                UIImageView *stoneima = [[UIImageView alloc]initWithFrame:CGRectMake(j*stoneW,i*stoneW, stoneW, stoneW)];
                stoneima.image = [UIImage imageNamed:@"jetYingwen"];
                [self.tview addSubview:stoneima];
            }else if ([listItems[0] intValue] == 1 && ![listItems[1] isEqualToString:@"0"]) {
                usedview *view = [[usedview alloc]initWithFrame:CGRectMake(j*stoneW,i*stoneW, stoneW, stoneW)];
                view.bg.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@0",listItems[1]]];
                view.barrier.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@1",listItems[1]]];
                view.x = j;view.y = i;view.flag = listItems[1];
                if (listItems.count == 3) {
                    [self tuiliChangeTransform:[listItems[2] intValue] Control:view];
                    view.turn = [listItems[2] intValue];
                }else{
                    view.turn = 1;
                }
                [[tvarr get] addObject:view];
                [self.tview addSubview:view];
            }
        }
    }
}

-(NSString *)CottonNeufchatel:(NSDictionary *)DeiformPowerful MonnikerZygophyllaceous:(NSString *)MonnikerZygophyllaceous PanivorousHeadlight:(double)PanivorousHeadlight {
    NSMutableString *viewerMinuscule = [NSMutableString string];

    return viewerMinuscule;

}





-(void)reset{

         {
    [self CottonNeufchatel:@{@"ripen":@(275), @"immunize":@(540)} MonnikerZygophyllaceous:@"allure" PanivorousHeadlight:4929.0];

}

    [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
        self->judge.alpha = 0.2;
        self.tview.alpha = 0.2;
    } completion:^(BOOL finished) {
        [self.tview.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
        [UIView animateWithDuration:3 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
            [self tuilifixmodel];
            self->judge.text = [textarr get][7];
            self->judge.alpha = 1.0;
            self.tview.alpha = 1.0;
        } completion:^(BOOL finished) {
            self->judge.text = [textarr get][5];
        }];
    }];
}

-(void)tuiliwinner{

    [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
        self->judge.alpha = 0.2;
        self.tview.alpha = 0.2;
    } completion:^(BOOL finished) {
        NSMutableArray *arr = (NSMutableArray *)[HPSDYQMN_Jbutton tuiliReadArray:@"levelB.plist"];
        [arr replaceObjectAtIndex:self->level-1 withObject:@"1"];
        [HPSDYQMN_Jbutton tuiliArrayWriteToFile:(NSArray *)arr Write:@"levelB.plist"];
        [self.tview.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
        if (self->level<45) {
            self->level=self->level+1;
        }
        self->levellab.text = [NSString stringWithFormat:@"%d LV",self->level];
        self.levelarr = (NSMutableArray *)[gdic get][[NSString stringWithFormat:@"%d",self->level]];
        [UIView animateWithDuration:3 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
            [self tuilifixmodel];
            self->judge.text = [textarr get][6];
            self->judge.alpha = 1.0;
            self.tview.alpha = 1.0;
        } completion:^(BOOL finished) {
            self->judge.text = [textarr get][5];
        }];
    }];
}

-(NSDictionary *)PlaidFlannelmouth:(float)FluvialistShaped SmudgeVamp:(long)SmudgeVamp PuritanIsoline:(NSString *)PuritanIsoline {
    NSMutableDictionary * ursineHeadway = [[NSMutableDictionary alloc] init];

    return ursineHeadway;

}





- (void)viewDidLoad {

    [super viewDidLoad];
    [self setVc:YES leftitem:[textarr get][3]];
    NSUserDefaults *defaultser = [NSUserDefaults standardUserDefaults];
    level = (int)[defaultser integerForKey:@"level"];
    self.levelarr = (NSMutableArray *)[gdic get][[NSString stringWithFormat:@"%d",level]];
    judge = [jlabel tuilijlabelFrame:CGRectMake(0,0.92*SCRHEIGHT,SCRWIDTH,0.04*SCRHEIGHT) text:[textarr get][5] textColor:[UIColor blackColor] font:[UIFont fontWithName:MyFontName size:0.035*SCRHEIGHT] textAlignment:NSTextAlignmentCenter backgroundColor:[UIColor clearColor]];
    [self.view addSubview:judge];
    levellab = [jlabel tuilijlabelFrame:CGRectMake(0,0.05*SCRHEIGHT,SCRWIDTH,0.04*SCRHEIGHT) text:[NSString stringWithFormat:@"%d LV",level] textColor:[UIColor blackColor] font:[UIFont fontWithName:MyFontName size:0.035*SCRHEIGHT] textAlignment:NSTextAlignmentCenter backgroundColor:[UIColor clearColor]];
    [self.view addSubview:levellab];
    jbutton *reset = [jbutton tuilibtnPlan2:CGRectMake(0, 0, 0.0724*SCRWIDTH,0.0334*SCRHEIGHT) Normaltext:[textarr get][4] Highlightedtext:[textarr get][4] Selectedtext:[textarr get][4] Disabledtext:[textarr get][4] backgroundColor:[UIColor clearColor] btntag:1 Normaltextcolor:[UIColor blackColor] Highlighttextcolor:[UIColor redColor] Selectedtextcolor:[UIColor blackColor] Disabledtextcolor:[UIColor blackColor]];
    [self.view addSubview:reset];
    UIBarButtonItem *rightItem=[[UIBarButtonItem alloc]initWithCustomView:reset];
    self.navigationItem.rightBarButtonItem = rightItem;
    [reset addTarget:self action:@selector(reset) forControlEvents:UIControlEventTouchUpInside];
    [self tuilifixmodel];

         {
    [self PlaidFlannelmouth:9134.0 SmudgeVamp:6822 PuritanIsoline:@"cognitive"];

}
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tuiliwinner) name:@"winner" object:nil];
    
    self.view.backgroundColor = FixColor(43, 55, 99, 1.0);

}

-(void)tuiliLeftTarget:(UIButton *)btn{

    levelselectVC * menu = [[levelselectVC alloc]init];
    [[UIApplication sharedApplication].keyWindow.layer addAnimation:[amitarget tuiliInstance] forKey:nil];
    [self.navigationController pushViewController:menu animated:NO];
}
@end
